package top.kaoshanji.ch05;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.ch05.inheritance.Employee;
import top.kaoshanji.ch05.inheritance.Manager;

/**
 * 代码清单 ch05-01：继承示例(员工与经理计算薪水的区别)
 * @see top.kaoshanji.ch05.inheritance.Employee
 * @see top.kaoshanji.ch05.inheritance.Manager
 * author kaoshanji
 * ^_^
 * create time 2024/11/25 18:13
 */
public class InheritanceTest {

    private static final Logger logger = LogManager.getLogger(InheritanceTest.class);

    public static void main(String[] args) {
        logger.info("...代码清单 ch05-01：继承示例(员工与经理计算薪水的区别)...");

        // 构造一个 Manager 对象
        var boss = new Manager("Carl Cracker", 80000, 1987, 12, 15);
        boss.setBonus(5000);

        var staff = new Employee[3];

        staff[0] = boss;
        staff[1] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
        staff[2] = new Employee("Tommy Tester", 40000, 1990, 3, 15);

        for (Employee e: staff) {
            // 变量e 既可以访问 Employee 对象，也可以访问 Manager 对象
            System.out.println("name=" + e.getName() + ", salary=" + e.getSalary());
        }

    }

}
